package com.ruoyi.factorydata.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.factorydata.mapper.CustomerTypeDataMapper;
import com.ruoyi.factorydata.domain.CustomerTypeData;
import com.ruoyi.factorydata.service.ICustomerTypeDataService;

/**
 * 客户类型Service业务层处理
 *
 * @author ruoyi
 * @date 2025-07-03
 */
@Service
public class CustomerTypeDataServiceImpl extends ServiceImpl<CustomerTypeDataMapper, CustomerTypeData> implements ICustomerTypeDataService {
    @Autowired
    private CustomerTypeDataMapper customerTypeDataMapper;

    /**
     * 查询客户类型
     *
     * @param id 客户类型主键
     * @return 客户类型
     */
    @Override
    public CustomerTypeData selectCustomerTypeDataById(Long id) {
        return customerTypeDataMapper.selectCustomerTypeDataById(id);
    }

    /**
     * 查询客户类型列表
     *
     * @param customerTypeData 客户类型
     * @return 客户类型
     */
    @Override
    public List<CustomerTypeData> selectCustomerTypeDataList(CustomerTypeData customerTypeData) {
        return customerTypeDataMapper.selectCustomerTypeDataList(customerTypeData);
    }

    /**
     * 新增客户类型
     *
     * @param customerTypeData 客户类型
     * @return 结果
     */
    @Override
    public int insertCustomerTypeData(CustomerTypeData customerTypeData) {
                customerTypeData.setCreateTime(DateUtils.getNowDate());
            return customerTypeDataMapper.insertCustomerTypeData(customerTypeData);
    }

    /**
     * 修改客户类型
     *
     * @param customerTypeData 客户类型
     * @return 结果
     */
    @Override
    public int updateCustomerTypeData(CustomerTypeData customerTypeData) {
                customerTypeData.setUpdateTime(DateUtils.getNowDate());
        return customerTypeDataMapper.updateCustomerTypeData(customerTypeData);
    }

    /**
     * 批量删除客户类型
     *
     * @param ids 需要删除的客户类型主键
     * @return 结果
     */
    @Override
    public int deleteCustomerTypeDataByIds(Long[] ids) {
        int i = customerTypeDataMapper.deleteBatchIds(Arrays.stream(ids).collect(Collectors.toList()));
        return i;
    }

    /**
     * 删除客户类型信息
     *
     * @param id 客户类型主键
     * @return 结果
     */
    @Override
    public int deleteCustomerTypeDataById(Long id) {
        return customerTypeDataMapper.deleteCustomerTypeDataById(id);
    }
}